﻿using EasyClassWEBAPI.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Reflection.Metadata;
using System.Threading.Tasks;

namespace EasyClassWEBAPI.EntityClass
{
    public class StudyGroup
    {
        [Key]
        [ScaffoldColumn(false)]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int StudyGroupID { get; set; }
        [Required]
        public string StudyGroupName { get; set; }
        [Required]
        public string Category { get; set; }
        [Required]
        public string Description { get; set; }//小组的描述
        
        public string Members { get; set; }//用来存放已经加入此小组的成员（将链表序列化成字符串存储）

        public User User { get; set; }

        public List<StudyResource> StudyResources { get; set; }
        //StudyGroup与Post一对多的关系
        public List<Post> Posts { get; set; }

        public override bool Equals(object obj)
        {
            return obj is StudyGroup group &&
                   StudyGroupID == group.StudyGroupID;
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(StudyGroupID);
        }
    }
}
